#include <stdio.h>  
  
#define MAX_SIZE 100005  
  
int a[MAX_SIZE];  
int sum[MAX_SIZE];  
  
int main() {  
    int n, m;  
    scanf("%d %d", &n, &m);  
  
    sum[0] = 0;  
    for (int i = 1; i <= n; i++) {  
        scanf("%d", &a[i]);  
        sum[i] = a[i] + sum[i - 1];  //求前缀和
    }  
  
    while (m > 0) {  
        m--;  
        int l, r;  
        scanf("%d %d", &l, &r);  
        printf("%d\n", sum[r] - sum[l - 1]);//对每个[l,r]区间的求和操作都转化为对断电[r]-[l-1]的操作
    }  
  
    return 0;  
}